Repository navigation
perf(console): the first load stops downloading the Setup pages, the package form and the view config panel - #33580
Conversation
The Setup and metadata pages registered in builtinComponents.tsx were imported by value, and ObjectView imported ViewConfigPanel statically, so the Packages page, its form dialog, the permission-matrix editor, SchemaForm and the Studio form widgets were all in the console's eager closure on every route. Each now loads behind lazy() with its Suspense boundary inside the registered value or around the panel. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mmCUzPNeT1C9cHRtT
…w config panel Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mmCUzPNeT1C9cHRtT
|
domain:ui#2 · os-project-manager · session_01FEkQ5oF8GgTHN2jBZoDwz8 席位核对Verdict: ACCEPT · head
|
…record view and the list view package (objectstack-ai#33677) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XQiZMH6HiMoqxNgbryZTptN)_ Part of objectstack-ai#33581 (PR 1 of the card: the boundaries; the helper subpaths are PR 2, not this one) Clause-②: no Metadata-protocol: none Seat `domain:ui#1` · os-project-manager · card thread `session_01FEkQ5mBsWKVFHwHpfLNx3a` · claim 6889356674 ## 维护者速读 - 改了什么:控制台首次加载不再预先下载对象列表页(默认列表与保存的列表视图)、记录详情视图和 `@object-ui/plugin-list`(列表视图与画廊)。列表页改为和其它路由页一样按需加载(路由一确定就开始下载);记录详情在抽屉里第一次打开记录时才下载;`list-view`、`view:list`、`object-gallery` 三个标签改为懒加载注册。首屏脚本从 2,165,721 字节(gzip)降到 2,060,434 字节,少了约 105 KB(4.9%)。 - 为什么改:objectstack-ai#33581 测得仪表盘等任何路由都要先下载表格、表单、记录详情等约 287 KB 才开始取数。本 PR 去掉其中能在不动共享包接口的前提下去掉的部分:`RecordDetailView` 与 `plugins-views` 两块整块离开首屏,五块合计 287,260 → 220,463 字节。 - 风险与回滚:只改加载时机,不改任何页面画什么;8 条路由在构建好的 showcase 控制台里改前改后各测一遍,全部画出、无页面错误。抽屉里第一次打开记录时多一帧详情骨架屏。`plugin-grid`、`plugin-form`、`plugin-view` 仍在首屏:它们被控制台外壳按名字导入的辅助函数拉住(拆它们要给共享包新增无副作用子路径,属 PR 2),详见 Acceptance notes。回滚即还原本 PR。 - 先看:ui/packages/app-shell/src/console/AppContent.tsx(`ObjectView` 改为 `routeChunk.lazy` 并加入预加载表)、ui/apps/console/src/register-plugins.ts(`plugin-list` 改为三条 `registerLazy`)、ui/scripts/vite-declared-lazy-views.ts(新的正控 `ConsoleLayout` 与新台账 `DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS`)。 - 两分钟验证:在 `ui/apps/console` 跑 `CI=true pnpm exec vite build`,读 `dist/eager-closure.json` 的 `eagerGzipBytes`,应约为 2,060,434;打开任一对象列表点开一条记录,抽屉正常画出详情。 - 需要你做的:无,席位落地。 ## What changes Measured first, on `origin/main` `3c0033f9`, with objectstack-ai#33580's instrument (the console's own `vite.config.ts` run through Vite's `build()` with one read-only plugin dumping the module graph; same `eager-closure.json` as a plain build): **107 eager chunks, 2,165,721 B gzip**. The five chunks the card names: `plugin-grid` 160,144 · `plugin-form` 44,267 · `RecordDetailView` 27,317 · `plugins-views` (plugin-list + plugin-detail group) 39,465 · `plugin-view` 16,067 = **287,260 B**. Three cuts, in the order the order lists them: 1. **`ObjectView` is a route element.** `console/AppContent.tsx` declared it in its always-eager block; it is now `routeChunk.lazy(() => import('../views/ObjectView.js'))` like the other route views, and its two paths (`:objectName`, `:objectName/view/:viewId`) join `APP_ROUTE_CHUNKS`, so its chunk starts downloading as soon as the route is known, in parallel with the route's metadata reads (the existing `preloadableLazy` path). `ObjectNotFoundState`, which AppContent also draws, is imported from its own module (`views/objectViewChrome.js`) instead of through `ObjectView.js`. `ObjectView.tsx` itself is not touched. 2. **`RecordDetailView` is lazy in the record pane.** `views/objectViewRecordOverlay.tsx` imported it statically; it is now `lazy()` inside a `Suspense` whose fallback is the existing `SkeletonDetail`. With cut 1 alone the view already leaves the first load (the overlay rides in the `ObjectView` chunk); this boundary keeps it out of the list route too, so a list that never opens a record never downloads it (probe below: `list` requests no `RecordDetailView` chunk, `list-drawer` does). 3. **`plugin-list` registers lazily.** `apps/console/src/register-plugins.ts` bare-imported five plugins. Measured one at a time by dropping each import: only `@object-ui/plugin-list` moves the closure (−40,068 B, the whole `plugins-views` chunk). It now registers `list-view`, `view:list` (`skipFallback`) and `object-gallery` as `registerLazy` stubs with the namespaces the package itself registers. `plugin-grid`, `plugin-form`, `plugin-view` and `plugin-detail` stay eager imports: each is held by another eager edge (Acceptance notes), so a stub would move nothing; the order's "as far as the measure shows a closure win". `ui/scripts/vite-declared-lazy-views.ts` follows the graph: - `EAGER_WALK_CONTROL`, counter-probe 2's positive control, was `ObjectView.tsx`, which is no longer eager. It is now `packages/app-shell/src/layout/ConsoleLayout.tsx`, imported by the same always-eager block and drawn around every route. - The plugin's `missing` half fired on the cut build for `RecordDetailView.tsx` (pinned, no longer eager), so its line leaves `DECLARED_LAZY_VIEWS_STILL_EAGER`, which is now empty. - Unpinned, `RecordDetailView.tsx` would be declared `moduleSideEffects: false`, and guard 2 rightly refuses that: it bare-imports `./record-approvals-renderer.js`. A new frozen ledger, `DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS`, lists declared-lazy views the plugin weighs like the rest (eager and unpinned still fails the build) but never declares pure. The plugin refuses a stale entry (no bare side-effect import and not named in its package's `sideEffects` array). `RecordDetailView` is lazy without the declaration, measured: nothing in the eager graph reaches it but the package barrel, which the package's own `sideEffects` array already leaves shakeable. Result on the same instrument, head `b5429992` (sources identical to the measured build): **103 eager chunks, 2,060,434 B gzip, −105,287 B (−4.9%)**. The real console build (`pnpm --filter @object-ui/console build`, tsc + vite + manifest) reads 2,165,724 → 2,060,438 on the same two trees; the 3–4 B is build-to-build variance. | chunk (card) | before, B gz | after | status | |:--|--:|--:|:--| | `RecordDetailView` | 27,317 | — | **left the eager closure** | | `plugins-views` (plugin-list + detail group) | 39,465 | — | **left the eager closure** | | `plugin-grid` | 160,144 | 160,137 | eager, held elsewhere (notes) | | `plugin-form` | 44,267 | 44,270 | eager, held elsewhere (notes) | | `plugin-view` | 16,067 | 16,056 | eager, held elsewhere (notes) | | **five-chunk sum** | **287,260** | **220,463** | **−66,797** | Also left: `objectViewTitleSwitcher` (16,825), most of `index` (137,209 → 108,359), `newViewSpec`, `PageHeader`, `createDerive`, `recordDetailSections`, `MetadataInspector`, `useDatasetCatalog`, `deriveRelatedLists` and a few small ones. Seven small chunks appear (largest `studioScope` 12,223, `objectViewChrome` 5,298, `recordDrawerStack` 4,760): modules that were already eager inside `index` and the chunks that left, regrouped by rolldown, ⛔ not new first-load bytes (the total is the measure). The eager-closure gate's ceiling does not move; `BASELINE` is untouched. Changeset `.changeset/33581-console-eager-closure-list-and-record.md`: `@object-ui/console` patch (app-shell is private; the console's `dist` ships it, and `register-plugins.ts` is the console's own). ## Tests - `scripts/__tests__/vite-declared-lazy-views.test.ts` (34 tests, pass): the control is read from AppContent's `ConsoleLayout` import line; `ObjectView.tsx` is a parsed declaration (13 files, was 12); the new ledger is sorted, exists, is declared lazy, and every entry really carries a bare side-effect import and is not also pinned eager; the "every unpinned declared view is pure" pin excludes it; the attached-prose pins cover the new constant; the eager ledger records empty. - Console registry suites read `list-view` from its package now that the console registers a stub: `public-contract.test.ts` lists `list-view` among the tags reached through a pending stub; `registry-inputs-spec-parity.test.ts` and `htmlTierDataSourceInputDeclaration-6678.test.tsx` import `@object-ui/plugin-list` beside `register-plugins`, the remedy `registry-inputs-spec-parity` already uses for kanban, calendar, tree, map, gantt and timeline, and the way `dev/manifest-registry.ts` loads it before writing the published manifest. - Affected suites, from `ui/` under the lock: every `AppContent.*` suite (app-shell and console), every `ObjectView.*` suite (the record drawer opens through the lazy pane in `ObjectView.recordDrawer-27545` and the record-open pins), the four `RecordDetailView` suites that mount the overlay, and all 22 suites that import `register-plugins`: **178 files, 1886 tests**. First run: 175 files passed, 3 failed (the three registry suites above, 8 tests, all reading `list-view` as eagerly loaded); after the fix the three pass (285 tests). - `pnpm --filter @object-ui/app-shell run type-check`: exit 0. ESLint `--no-inline-config` on the eight changed source and test files: 0 errors (53 pre-existing warnings, none on a changed line). **Ablations** (`scripts/ablation-replace.mjs`, each restore proven: blob equal to HEAD, `git diff HEAD` empty): - New control: `EAGER_WALK_CONTROL` pointed back at the lazy `ObjectView.tsx` ⇒ the console build fails, `counter-probe failed: packages/app-shell/src/views/ObjectView.tsx is not in the eager closure`. The probe still fires. - Stale side-effect entry: the ledger line `RecordDetailView.tsx` replaced by the pure `ObjectView.tsx` ⇒ the build fails, `ObjectView.tsx is in DECLARED_LAZY_VIEWS_WITH_SIDE_EFFECTS but carries no bare side-effect import ...`. - Record pane boundary put back to a static import ⇒ build green, closure 2,059,952 (−482 B against head: regrouping), and the graph shows `RecordDetailView` as a static import of the `ObjectView` chunk. As stated in cut 2: on the first load the record pane boundary is neutral; it is the list route's saving, which the browser probe reads. - Nothing catches the plugin-list import coming back (+40,068 B): `check:eager-closure`'s sensitivity is 695 KiB by ruling, the reading objectstack-ai#33580 recorded. No pin is added (a new gate). ## Acceptance notes **What still holds the three remaining chunks** (module graph of the cut build, shortest eager chunk path): - `plugin-grid`: `hooks/sharedUserFeeds.ts` (reached from `ConsoleShell` → `useUserLocale` / `useHomeInbox`) imports `@object-ui/plugin-detail`, which the `plugin-grid` group captures; dropping every bare import in `register-plugins.ts` and the `dev/DevRowActions` edge too still leaves it eager. The eleven `plugin-detail` reach-ins are PR 2's. - `plugin-form`: `providers/MetadataProvider.tsx`, `console/AppContent.tsx` and `apps/console/src/components/FormPage.tsx` import named helpers from the package entry, which keeps the whole registering entry (PR 2's side-effect-free subpaths). - `plugin-view`: `console/AppContent.tsx` imports `deriveRecordSurface` / `deriveRecordFlowSurface` from the entry (PR 2). - `apps/console/src/App.tsx` imports `dev/DevRowActions.tsx` (a dev-only `/dev/row-actions` harness) statically, an `ObjectGrid` edge into `plugin-grid`. Measured inert today (−934 B when cut, because the edges above hold the chunk); it becomes a real edge once PR 2 lands. `carrier: objectstack-ai#33581 PR 2`. - A `list-view` / `object-gallery` stub carries only the namespace and category until the package loads, so `ComponentRegistry.getConfig` answers no `inputs` for them before first use, the same as every other lazy plugin (kanban, calendar, dashboard). The published manifest is built by `dev/manifest-registry.ts`, which imports the package eagerly, so `sdui.manifest.json` is unchanged (`node scripts/check-sdui-manifest.mjs` exit 0). - The seat note to use `React.lazy` at the boundary and not a second lazy wrapper is followed: the record pane uses `React.lazy`, the route uses AppContent's own `routeChunk.lazy`; no shared `lazyPage` helper is needed. **A built console in a real browser, before and after.** Showcase built at this tree (`pnpm --filter '@objectstack/example-showcase...' build`), the console built for real (`pnpm --filter @object-ui/console build && pnpm --filter @objectstack/console build:dist`) once with the base sources (`3c0033f9`'s `ui/packages/app-shell/src`, `ui/apps/console/src`, `ui/scripts`) and once at head, each served by `pnpm dev --fresh` from `examples/app-showcase`; headless Chromium, a fresh context (cold cache) per route, signed in as the dev admin. "chunks" = which of the watched chunks the route requested. | route | before: drew · chunks | after: drew · chunks | |:--|:--|:--| | dashboard `showcase_ops_dashboard` | yes · RecordDetailView, plugins-views | yes · **none of** ObjectView, RecordDetailView, plugins-views | | list `showcase_task` | yes (10 rows) · RecordDetailView, plugins-views | yes (10 rows) · ObjectView, plugins-views; **no** RecordDetailView | | list + drawer `?recordId=` | yes, drawer open | yes, drawer open · ObjectView, plugins-views, RecordDetailView | | record page `/record/ID` | yes | yes · RecordDetailView; **no** ObjectView, plugins-views | | saved view `view/cards` (gallery, `object-gallery` stub) | yes | yes · ObjectView, plugins-views | | saved view `view/board` (kanban) | yes | yes · ObjectView, plugins-views | | Studio `/studio` | yes | yes | | Setup → Packages | yes | yes · none of the three | No page error, no console error, no failed request on any route, before or after. The page text length is identical before and after on every route that does not show a record (1638, 2092, 1643, 1812, 1147, 1092 characters); the two record routes show a different record on each run (`--fresh` seeds new ids), so their lengths differ by the record. Screenshots, `routes.json` for both runs, the probe and both `eager-closure.json` files are in the project folder `pm-orders/ui/33581-probe/`. ## Verification All on head `b5429992`. `node scripts/pm/dispatch-gates.mjs --ran` answers: 44 derived families accounted for, 44 run, 0 NOT-MEASURED. - Affected tests: 178 test files, 1886 tests pass (app-shell, console and `ui/scripts` suites touching the changed files). - `pnpm --dir ui exec vitest run scripts/` (under the shared verify lock): 171 files passed, 2 skipped; 5065 tests passed, 2 skipped. - `ui/scripts/__tests__/vite-declared-lazy-views.test.ts`: 34 passed. - app-shell type-check exit 0; ESLint on the changed files: 0 errors. - `pnpm --dir ui check:eager-closure`, `check:side-effects-array`, `check:sdui-registration-pins`, `check:eager-locale-catalogues`, `check:new-line-citations`: exit 0 each. Every derived gate command and its exit code: ```text node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-dts-emitted.mjs --self-test :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-sdui-manifest.mjs :: exit 0 node scripts/check-sdui-manifest.mjs --self-test :: exit 0 node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:dts-closure :: exit 0 pnpm check:dual-build-cjs-loads :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:lean-entry-closure :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:skill-identifier-liveness :: exit 0 pnpm check:sourcemap-no-sources-content :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 pnpm --dir ui check:eager-closure :: exit 0 pnpm --dir ui check:side-effects-array :: exit 0 pnpm --dir ui check:sdui-registration-pins :: exit 0 pnpm --dir ui check:eager-locale-catalogues :: exit 0 pnpm --dir ui check:new-line-citations :: exit 0 pnpm --dir ui exec vitest run scripts/ :: exit 0 ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5mBsWKVFHwHpfLNx3a --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5mBsWKVFHwHpfLNx3a)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
…trings and the metadata form strings (objectstack-ai#33682) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X1BWM1V5bGUHJAmMNYdGNXk)_ Fixes objectstack-ai#33582 Clause-②: no Metadata-protocol: none Seat `domain:ui#2` · os-project-manager · card thread `session_01FEkQ5ousB2MKFUbJFc3Hwp` · claim 6889348795 and its two amendments ## 维护者速读 - 改了什么:控制台首次加载不再预先下载 Studio 设计器的英文字符串(64 KB gzip)和元数据表单字符串;它们改为在 Studio、Setup 或列表页真正用到时才下载。任何路由的首屏脚本从 2,165,707 字节(gzip)降到 2,058,464 字节,少了 107,243 字节(5.0%),首屏块从 107 个降到 103 个。 - 为什么改:objectstack-ai#33582(objectstack-ai#33293 的拆分卡)测得仪表盘等路由在取数前就要下载这两份字符串,而只有 Studio 和 Setup 画它们。把它们拽进首屏的是五个在加载时就注册或挂载的组件:Studio 画布的默认对象表格、Setup 数据源页、岗位列表的两个单元格、列表的「新建视图」对话框、预览条的「待发布更改」面板;现在都改为第一次画出时才加载。 - 风险与回滚:只改加载时机,不改任何界面画什么;英文仍是 Studio 字符串的同步兜底(objectstack-ai#25922 不变)。数据源页首次打开时多一行「Loading…」;岗位列表两列在代码到达前留空一瞬;列表页挂载时会顺带下载「新建视图」对话框及其字符串(与 objectstack-ai#33580 的视图配置面板同一形状)。回滚即还原本 PR。 - 先看:ui/packages/app-shell/src/views/studio-design/studio-canvas-preview.tsx(默认画布改为按需加载并以同名导出注册,StudioDesignSurface 的身份比较不受影响)、ui/packages/app-shell/src/services/lazyPage.tsx(从 builtinComponents.tsx 移出的唯一 lazyPage 包装,加了可选 fallback)、ui/apps/console/vite.config.ts(新增 i18n-ns-studio 分块组)。 - 两分钟验证:`pnpm --filter '@object-ui/console^...' build` 后在 `ui/apps/console` 跑 `CI=true pnpm exec vite build`,读 `dist/eager-closure.json`:`eagerGzipBytes` 应为 2,058,464 左右,`files` 里不再有 `i18n-ns-studio-en` 和 `metadata-form-i18n`。 - 需要你做的:无,席位落地。 ## What changes Measured first on `origin/main` `3c0033f9` with the instrument objectstack-ai#33580 used (the console's own `vite.config.ts` run through Vite's `build()` plus one read-only plugin that dumps `getModuleInfo()` and every chunk's module list; that build writes the same `eager-closure.json` as a plain build): **107 eager chunks, 2,165,707 B gzip**. `i18n-ns-studio-en` (64,296 B) and `metadata-form-i18n` (11,363 B) are eager. The edges, read from that graph (eager importers only): | module | eager importer(s) on main | cut here | |:--|:--|:--| | `packages/i18n/src/namespaces/studio/index.ts` | `metadata-admin/i18n.ts`; the module itself sits in the eager `i18n-runtime` group, with its static `en` edge | new `i18n-ns-studio` chunk group | | `metadata-admin/i18n.ts` | `studio-design/studio-canvas-preview.tsx`, `metadata-admin/datasource/DatasourceResourcePage.tsx`, `metadata-admin/PositionGrantCells.tsx`, `metadata-admin/previews/useDatasetCatalog.ts` | all four, below | | `metadata-admin/metadata-form-i18n.ts` | `preview/changeKeyLabels.ts` only, through `preview/DraftChangesPanel.tsx`, mounted closed by `preview/DraftPreviewBar.tsx` (in `ConsoleLayout`) | `DraftChangesPanel` lazy | The cuts, each the objectstack-ai#33580 shape: - **`services/lazyPage.tsx` (new).** objectstack-ai#33580's `lazyPage` moves here from `builtinComponents.tsx` unchanged, so the three registration sites below share the one wrapper. It gains an optional third argument, `fallback`, so a list cell draws nothing while its module loads instead of the page-sized loading line. `builtinComponents.tsx` imports it (and its fallback, still used by the two metadata-admin registrations). - **`studio-design/studio-canvas-preview.tsx`** is imported by the package entry for its load-time `registerStudioCanvasPreview('object', …)` (it is in app-shell's `sideEffects`). The default grid and everything only it reads (the `@object-ui/react` renderer hooks, `useAuth`, the designer strings) move verbatim to **`studio-design/studio-object-records-canvas.tsx`**. The registry module keeps the registry, the contexts, `navEntryListTarget` and `listViewsOf`, and exports `StudioObjectRecordsCanvas` as `lazyPage('studio canvas', () => import('./studio-object-records-canvas.js'))`. The name is unchanged and is the value registered, so `StudioDesignSurface`'s `StudioCanvas === StudioObjectRecordsCanvas` check and the package entry's re-export need no edit. - **`metadata-admin/datasource/register.ts`** registers `DatasourceResourcePage` through `lazyPage`, typed with the registry's `ListPage` props `{ type: string }`. - **`services/builtinComponents.tsx`**: the position list's `PositionHolderCountCell` and `PositionGrantedSetsCell` are `lazyPage(…, null)`; the column `render` functions are unchanged. - **`views/ObjectView.tsx`**: `CreateViewDialog` is `lazy()` with its mount inside `Suspense fallback={null}`, exactly as `ViewConfigPanel`. Nothing else in the file changes. - **`preview/DraftPreviewBar.tsx`** (seat amendment 2): `DraftChangesPanel` is `lazy()` with its mount inside `Suspense fallback={null}`. The bar draws only in preview mode, so the sheet's chunk is requested only there. - **`ui/apps/console/vite.config.ts`**: an `i18n-ns-studio` group for `namespaces/studio/index.ts` with `includeDependenciesRecursively: false`, beside the existing `i18n-ns-studio-en` / `-zh` groups and for the reason the marketplace loader's group gives. `en` stays a static import of the namespace module, so it stays the synchronous fallback (objectstack-ai#25922); the module and its `en` catalogue leave the eager closure together. Result, final head `58e603fe`, two builds of the same tree: **103 eager chunks, 2,058,464 B gzip** both times (the console:build dist served in the live check read the same), **−107,243 B (−5.0%)** against main. | chunk | before, B gz | after | |:--|--:|:--| | `i18n-ns-studio-en` | 64,296 | **left the eager closure** | | `metadata-form-i18n` | 11,363 | **left the eager closure** | | `i18n` | 8,085 | left | | `json-schema-to-fields` | 1,882 | left | | `object-fields-io` | 1,578 | left | | `useDatasetCatalog` | 1,059 | left | | `objectViewTitleSwitcher` | 16,823 | 8,131 | | `src` | 38,144 | 31,115 | | `newViewSpec` | 4,236 | 309 | Three small eager chunks appear: `usePendingDrafts` (1,490), `drillUrlFilters` (1,454) and `studio-canvas-preview` (919). They are modules that were already eager inside chunks that shrank, regrouped by rolldown; not new first-load bytes. `pnpm check:eager-closure` on that build: exit 0, aggregate 2010.2 KB / 2431.6 KB ceiling, headroom 421.4 KB = **0.61x** the 695.0 KB regression. `evaluateHeadroomSensitivity`'s predicate (headroom ≥ 1x) does not fire, so the gate asks for no re-pin; `BASELINE` is untouched. Changeset `.changeset/33582-console-eager-closure-studio-strings.md`: `@object-ui/console` patch (app-shell is private; the console's `dist` ships it). `Clause-②: no`: nothing a package exports changes shape; app-shell is private, its entry still exports `registerStudioCanvasPreview` with the same signature, and no `@object-ui/i18n` key is added or removed. ## Tests - **New pin** in `studio-canvas-preview.test.tsx`, "the registered object default loads the grid on first draw (objectstack#33582)": the registered default is the wrapper, not the grid module's own component, and drawn through `getStudioCanvasPreview('object')`, as `StudioDesignSurface` draws it, it loads and draws the grid with the schema the module's component renders. The file's existing grid-behaviour tests (objectui#11774, objectui#11823) now render the module's own component, imported at module scope (`ui/AGENTS.md`, lazy-boundary rule). - **Ablation** (`scripts/ablation-replace.mjs` on `studio-canvas-preview.tsx`, the wrapper's loader `.then((m) => m.StudioObjectRecordsCanvas)` replaced by one that resolves a component drawing nothing): "drawn through the registry, it loads and draws the grid" **red** (1 failed, 1 passed, 15 skipped); restore: blob equal to HEAD `88577d58c086`, `git diff HEAD` empty. - **Census row moved**: `console/__tests__/openPathObjectReaders-12811.test.ts` classifies every source file that reads `useMetadata().objects`; the reader moved with the grid, so its row names `studio-object-records-canvas.tsx` (same `kind: 'off'`, same reason). - **Affected suites**, from `ui/` under the lock: every `views/studio-design/*.test.ts(x)`, every test importing `ObjectView`, every `preview/*.test.tsx` and `CreateViewDialog*.test.tsx`, and every test naming the changed modules (`builtinComponents`, `PositionGrantCells`, the datasource registration, `register-builtins`): **500 files, 3,982 tests**. First run 498 files passed; the two red files were the canvas tests above (rendering the lazy name synchronously) and the census row. After the fix both files pass (20 / 20). The other 498 were not re-run after the test-only commit and the one-line type annotation. - `pnpm --filter @object-ui/app-shell run type-check` (both `tsc` passes): exit 0 on the final head. The first console `build:dist` caught `TS2322` on the datasource registration (an optional `type` prop inferred); fixed by typing the wrapper with those props. - eslint on the seven changed sources: 0 errors; warnings 70 on main to 60 here (the one new one is `react-refresh/only-export-components` on `lazyPage.tsx` exporting a function beside a component). - The `ineffective-dynamic-import` ledger ("41 ineffective dynamic imports, all pinned") and `declared-lazy-views` ("11/12 … 1 eager, all pinned") print the same lines as on main, so none of the new `import()`s is defeated by a static edge. ## Acceptance notes - **Card correction.** The card names four edges into `metadata-admin/i18n.ts` and says `metadata-form-i18n` rides the same edges. Measured on main, the four edges are exactly as named, but `metadata-form-i18n` is not held by them: its only eager importer is `preview/changeKeyLabels.ts`, reached through `preview/DraftChangesPanel.tsx`, which `preview/DraftPreviewBar.tsx` mounts closed. That edge also carried the `object-fields-io` straggler. The seat added `DraftPreviewBar.tsx` (the `DraftChangesPanel` import and mount only) to the claim before it was edited. - **Where the strings now load.** Studio and Setup screens load them as before. A list route also requests them as the list mounts, because `CreateViewDialog` is mounted closed with the list and its chunk carries the dataset catalogue, as `ViewConfigPanel` does since objectstack-ai#33580. They stay off the dashboard and every non-list route (live check below). - `ObjectView` itself is still eager (AppContent's always-eager block): that is objectstack-ai#33581's, not touched here. `AppContent` and `apps/console/src/register-plugins.ts` are not edited. - No out-of-scope finding to file. ## Verification Live, the built console (`turbo run build:dist --filter=@objectstack/console` at `58e603fe`) served by the showcase app (`objectstack dev --ui --seed-admin --no-watch`), a fresh browser context per route (cold cache, so every chunk the route needs is a request), Chromium via Playwright. Probe, screenshots and `routes.json`: `/mnt/project-files/pm-orders/ui/33582-probe/` in the project files. | route | draws | moved chunks requested | |:--|:--|:--| | dashboard `showcase_ops_dashboard` | yes, no page errors | **none** of `i18n-ns-studio-en`, `i18n-ns-studio`, `metadata-form-i18n`, the canvas, the datasource page, the position cells, `CreateViewDialog`, `DraftChangesPanel` | | task list, then view switcher → "Add new view" | the Create View dialog opens, English text ("Pick a view type, then give it a name…") | `CreateViewDialog`, `i18n-ns-studio(-en)`, `metadata-form-i18n` on list mount | | Studio → Interfaces → Tasks (object leaf) | the runtime records grid in the canvas, English Studio chrome | the canvas module on clicking the leaf | | Setup → Datasources | the datasources list (Default, External Analytics) | the datasource page, `i18n-ns-studio(-en)` | | position list (`metadata/position`) | Holders and Permission sets columns filled per row | the position cells | No route showed a raw `engine.*` string key or a console error. <details><summary>Gates (local, head 58e603f)</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`: 44 families. All run; 43 exit 0; `pnpm check:dual-build-cjs-loads` exit 3 (PREREQUISITE NOT MET: no `packages/qa/scenarios/dist`), NOT MEASURED, left to CI. `--ran` reconciliation: "44 derived famil(ies) accounted for — 43 run, 1 NOT-MEASURED". Per-family record: `/mnt/project-files/pm-orders/ui/33582-gates-ran.txt`. Outside the derived list: `pnpm --dir ui check:eager-closure` exit 0 (above). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5ousB2MKFUbJFc3Hwp)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5ousB2MKFUbJFc3Hwp --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Requested by Leehom · project thread
Fixes #33293
Clause-②: no
Metadata-protocol: none
Seat
domain:ui#2· os-project-manager · card threadsession_01FEkQ5mmCUzPNeT1C9cHRtT· claim 6886542738维护者速读
PackageFormDialog块已整块离开首屏。plugin-grid、plugin-form、RecordDetailView、Studio 英文语言包仍在首屏,原因与拆分建议见 Acceptance notes。回滚即还原本 PR。lazyPage,八个页面改成按需加载)、ui/packages/app-shell/src/views/ObjectView.tsx(ViewConfigPanel改为lazy()加Suspense)。pnpm --filter '@object-ui/console^...' build后在ui/apps/console跑CI=true pnpm exec vite build,读dist/eager-closure.json的eagerGzipBytes,应为约 2,163,689;打开/apps/setup/component/developer/packages,页面正常画出。What changes
Measured first, on
origin/maine3f0cfd4:CI=true pnpm exec vite buildinui/apps/consolewrotedist/eager-closure.json= 105 eager chunks of 2427, 2,293,387 B gzip (7,730,755 raw). The card's 2,286,732 B is the published 18.4.0 Console; same shape. The import edge that makes each named chunk eager was read from the build's own module graph (the console'svite.config.tsrun through Vite'sbuild()with one read-only plugin that dumpsgetModuleInfo()and each chunk's module list; that build wrote the sameeager-closure.jsonto the byte). The edges are tabled under Acceptance notes.Two edges are cut here, both by
lazy()with theSuspenseboundary inside what is rendered:services/builtinComponents.tsx, the app-shell module the package entry bare-imports for its registrations, imported eight pages BY VALUE:PackagesPage,PermissionMatrixEditPage,PackagedActionsPage,ConnectorCredentialsPage,ConnectorConnectionsPage,PositionHoldersPage,PermissionSetAssignmentPage,RecycleBinPage. Each, with everything it imports, sat in the eager closure;PackagesPage → PackageFormDialogis the card'sPackageFormDialogedge, andPositionHoldersPage → PositionHoldersSectionheld a 25.8 KB chunk. A newlazyPage(label, load)returns a component that renders the page behindlazy()+Suspense, the shape the file's two metadata-admin registrations already use, soregisterAppComponentandregisterMetadataResourcestill receive a component and no render site changes. The fallback is the file's existingMetadataAdminFallback("Loading packages…").views/ObjectView.tsximportedViewConfigPanelstatically.ObjectViewis in AppContent's always-eager block, so the panel heldViewVariantInspector,SchemaForm, the Studio form widgets (widgets.tsx,ConditionBuilder,CelPredicateField) andRuntimeDraftBareager. It is nowlazy()inside aSuspenseboundary whose fallback isnull, in the same wrapper div. The panel draws nothing while closed, so the list draws exactly as before; its chunk is requested as the list mounts.Result,
30cbab20(same instrument): 107 eager chunks of 2487, 2,163,689 B gzip (7,271,631 raw), −129,698 B (−5.7%). Two builds of this tree read 2,163,688 and 2,163,689; the 1 B is build-to-build variance, not attributed.PackageFormDialogSchemaForm/CelPredicateFieldco-tenants left too;object-fields-io, 1,575 B, andjson-schema-to-fields, 1,882 B, stay, see notes)plugin-gridplugin-formRecordDetailViewi18n-ns-studio-enAlso left:
PositionHoldersSection(25,809), most ofsrc(69,042 → 38,197),field-types(13,030),view-schema(5,292),MarketplaceLanguages(5,234),dist(4,845),ViewVariantInspector,ViewColumnPanes,RuntimeDraftBar,_sharedand four small chunks. Sixteen small eager chunks appear (largestmetadata-form-i18n11,364 andmarketplaceApi4,065): modules that were already eager inside the chunks that left, regrouped by rolldown, ⛔ not new first-load bytes.The eager-closure gate's ceiling does not move.
pnpm check:eager-closureon30cbab20: aggregate 2113.0 KB / 2431.6 KB, headroom 318.6 KB = 0.46x the 695.0 KB regression, soevaluateHeadroomSensitivity's one predicate (headroom ≥ 1x) does not fire and the gate's rules ask for no re-pin.BASELINEis untouched.Changeset
.changeset/33293-console-eager-closure-setup-pages.md:@object-ui/consolepatch (app-shell is private; the console'sdistships it).Tests
vite-declared-lazy-views(build plugin) and theineffective-dynamic-importledger both pass on the new build (exit 0, "41 ineffective dynamic imports, all pinned"), so no newimport()is defeated by a static edge elsewhere.scripts/ablation-replace.mjsonbuiltinComponents.tsx: thePackagesPageregistration re-imported statically), rebuilt and weighed under the lock: eager closure 2,223,296 B, 112 chunks,PackageFormDialogeager again;pnpm check:eager-closureexit 0 (2171.2 KB, headroom 260.4 KB). Restore: blob equal to HEADec73e832,git diff HEADempty. ⇒ Nothing catches an edge coming back: the gate's sensitivity is 695 KiB by ruling (objectui#12653), and a 60 KB regression is inside it. Adding a pin would be a new gate; none is added.ObjectViewand the registrations, fromui/under the lock: everypackages/app-shell/src/views/ObjectView*.test.tsx, the four Setup*.navContribution.test.tsx(each mounts its page throughComponentNavView, now through the lazy wrapper),ResourceListPage.positionGrants-25333,PermissionMatrixEditor.saveSurface-12725,PackagesPage.installedApps-13356: 85 files, 662 tests passed.ObjectView.viewConfigSaveWiring-10210,ObjectView.viewWriteRefusal-11583andObjectView.createViewRefusal-11578drive the panel through the realObjectView, so the lazy panel opens and saves through the input pipeline in those pins.Acceptance notes
Acceptance 1, per chunk. Edges read from the module graph of the
30cbab20build; "eager" = reachable from the entry chunk through static imports only.plugin-grid(159.6 KB; 73 of its modules areplugin-detail, which theplugin-gridgroup captures recursively becauseObjectGridimports it). Held byapps/console/src/register-plugins.ts(bareimport '@object-ui/plugin-grid'andplugin-detail, the SDUI registration of the core views),apps/console/src/App.tsx→dev/DevRowActions.tsx,@object-ui/plugin-view'sObjectViewand@object-ui/plugin-list'sListView(both eager the same way), and throughplugin-detailby eleven eager app-shell modules (sharedUserFeeds,deriveRelatedLists,workspacePreference,recordPagePayload,recordDetailSections,RecordPreviewCard, …).plugin-form(44.3 KB). Held byregister-plugins.ts,providers/MetadataProvider.tsx(resolveInlineMode),console/AppContent.tsxandhooks/useActionModal.tsx(ModalForm),utils/editFormLockedByState.ts(filterSystemFields,isAutoGeneratedFieldType),views/ActionParamDialog.tsx(useInitialFieldFocus),views/ScreenView.tsx,apps/console/src/components/FormPage.tsx, andplugin-view'sObjectView.plugin-formdeclares only its entry side-effectful, so a named helper import keeps the whole registering entry.RecordDetailView(27.3 KB). A real static edge:views/objectViewRecordOverlay.tsximports it andObjectViewsits in AppContent's always-eager block, the reasonui/scripts/vite-declared-lazy-views.tsalready pins it inDECLARED_LAZY_VIEWS_STILL_EAGER. The chunk also carriesNotFoundState,recordDrawerStackanduseObjectActions, whichAppContentimports directly.i18n-ns-studio-en(64.3 KB).namespaces/studio/index.tsimportsen.tsstatically by design (the synchronousenfallback, objectstack#25922), andindex.tsis eager twice over: thei18n-runtimegroup (/packages/i18n/) captures it into an eager chunk, and four eager modules import app-shell'smetadata-admin/i18n.ts:studio-design/studio-canvas-preview.tsx(bare-imported by the package entry for its load-timeregisterStudioCanvasPreview('object', …)),metadata-admin/datasource/register.ts(DatasourceResourcePageby value),PositionGrantCells(by value, frombuiltinComponents.tsx), andCreateViewDialog→objectDatasets→useDatasetCatalog.Why this PR stops here (the order's split clause). The seat filed the two remaining cuts as their own cards, #33581 (grid / form / RecordDetailView) and #33582 (the Studio
enstrings). Each remaining chunk needs a cut this card's bounds do not hold:ObjectViewin AppContent (it is alsoEAGER_WALK_CONTROL, the positive control ofvite-declared-lazy-views, so that plugin's counter-probe needs a new control);register-plugins.ts's five eager plugins turned intoregisterLazyper tag; and side-effect-free subpaths for the helpers app-shell imports from@object-ui/plugin-formand@object-ui/plugin-view(deriveRecordSurface,deriveRecordFlowSurface) — a shared-package API change (newexportsentries). Upper bound of the win: 286.7 KB gz (the five chunks' sum, part ofplugin-detaillikely staying).enneeds the default canvas preview instudio-canvas-preview.tsxmoved to a module of its own and registered lazily (a file split of about 400 lines in asideEffects-array module),DatasourceResourcePageand the two position cells registered lazily,CreateViewDialoglazy inObjectView, and ani18n-ns-studiogroup invite.config.tslikei18n-ns-marketplace. The synchronousenfallback stays (enremains a static import of the namespace module; the module itself moves out). Win: 64.3 KB gz plusmetadata-form-i18nand the modules only those four reach.PackageFormDialogchunk stay eager:object-fields-io(1,575 B, imported bypreview/DraftChangesPanel.tsx) andjson-schema-to-fields(1,882 B, viaDatasourceResourcePage, the Studioenedge above).Acceptance 3, a built console in a real browser. Showcase at this tree (
pnpm --filter '@objectstack/example-showcase...' build,turbo run build:dist --filter=@objectstack/console, thenobjectstack dev --ui --seed-adminfromexamples/app-showcase), headless Chromium, a fresh context (cold cache) per route, signed in as the dev admin:showcase_ops_dashboardViewConfigPanel,PackagesPage,PermissionMatrixEditor,PackageFormDialog,SchemaFormrequestedshowcase_taskViewConfigPanelrequested on mountshowcase_task/record/…/studioPackagesPage,SchemaFormfetched on demandPackagesPage,PackageFormDialogfetched on demandPositionHoldersPagefetched on demandmember_default(redirects to Studio)PermissionMatrixEditorfetched on demandNo page error, no console error, no failed request on any route. Screenshots, the probe and both
eager-closure.jsonfiles are in the project folderpm-orders/ui/33293-probe/. The record and Studio rows timed out on the probe's own wait selector (a hidden first match;mainnot visible) and drew, per their screenshots. Opening the view config panel by hand needs a saved view the showcase does not seed; the rendered pins above open it. Cold/warm timing was not re-measured.Verification
Local gates, type-check, lint (head 30cbab2)
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 30 families for this diff. All 30 exit 0 on30cbab20;--ran: 30 derived, 30 run, 0 NOT-MEASURED, 0 UNRUN.pnpm --dir ui exec vitest run scripts/read on its rerun: the first run (beside the showcase build,dist/mid-rebuild) had 4 files fail on unresolvable workspace imports; alone under the lock with--maxWorkers=2: 171 files passed, 2 skipped, 5062 tests passed, exit 0.pnpm check:eager-closureexit 0 (above).pnpm check:side-effects-array,pnpm check:sdui-registration-pins(71 registrations present, 2492 chunks weighed),pnpm check:eager-locale-catalogues,pnpm check:new-line-citations(0 new): exit 0.pnpm --filter @object-ui/app-shell run type-check: exit 0. ESLint--no-inline-configon the two changed source files: 0 errors (61 pre-existing warnings).🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5mmCUzPNeT1C9cHRtT
Generated by Claude Code